#ifndef QMESH_H
#define QMESH_H

#include "QMesh_global.h"
#include <QMap>
#include <QVector3D>
#include <QMatrix4x4>
#include <random>
#include <qgl.h>

#define QVERTEX 0x00
#define QNORMAL 0x01
#define QTEXCOORDS 0x02
#define QCOLOR 0x03

#define QINDICES 0x10

#define QFACEVERTEX 0x20
#define QFACENORMAL 0x21

#define QFACEINDICES 0x30

#define QUSER 0xa0

typedef unsigned int uint;
typedef QMap<int,uint> BufferObjectMap;

class QMESHSHARED_EXPORT QMesh
{
public:
    QMesh();

public:
    virtual int nVertices() = 0;

    virtual const float* Vertices() = 0;
    virtual const float* Normals() {return 0;}
    virtual const float* Colors() {return 0;}
    virtual const float* TexCoords() {return 0;}

    virtual uint* Indices() = 0;
public:
    virtual uint UploadArrayData(int index) = 0;
    virtual uint UploadElementData(int index) = 0;
    virtual void BindArrayBuffer(int index,int programLocation) = 0;
    virtual void DrawElements(int indicesIndex, GLenum mode) = 0;

public:
    virtual void Translate(QVector3D vec3d){Q_UNUSED(vec3d);}
    virtual void Rotate(QMatrix4x4 mat4x4){Q_UNUSED(mat4x4);}
    virtual void NormNoise(float mean, float std){Q_UNUSED(mean);Q_UNUSED(std);}

protected:
    BufferObjectMap m_vboMap;
    BufferObjectMap m_iboMap;
};

float normrnd(float E, float V);

#endif // QMESH_H
